<%@page import="controller.Utils"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="model.Domain"%>
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<%
Domain domain = (Domain) request.getAttribute("domain");

NumberFormat format = NumberFormat.getInstance();

long date = new Date().getTime();
long dates = new Date().getTime();
if(domain.getLastUpdate() != null)
{
	dates = Long.parseLong(domain.getLastUpdate().getValue());
}
long seconds = (date - dates)/1000;
long day = (int) (seconds / 86400);
long hour = (int) ((seconds - day*86400) / 3600);
long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
if(hour<0)
{
	hour = 0;	
}
if(minute<0)
{
	minute = 0;	
}
if(day<0)
{
	day = 0;	
}
String google = "0";
String alexa = "-";
String wot = ", "+domain.getName()+" has not been evaluated by wot.";
String ip = "";
String ips = "";
if(domain.getIp() != null&&!domain.getIp().equals("null"))
{
	ip = ", ip is "+domain.getIp();	
	ips = ","+domain.getIp();
}
if((domain.getGoogle() != null&&!domain.getGoogle().getValue().equals("null")))
{
	google = domain.getGoogle().getValue();
}
if((domain.getAlexa() != 0))
{
	alexa = ", there are "+format.getInstance().format((domain.getAlexa()-1))+" sites with a better three-month global Alexa traffic rank than "+domain.getName();
} else {
	alexa = ", "+domain.getName()+" has not been evaluated by alexa.";
}
if(domain.getWotChild() != null&&!domain.getWotChild().getValue().equals("null"))
{
	wot = ", Child Safety is "+domain.getWotChild().getValue()+"% under wot.";	
}

String descriptions = domain.getName()+" has google pagerank is "+google+ip+alexa+wot;

String title = domain.getName();
if(domain.getTitle() != null&&!domain.getTitle().getValue().equals("null"))
{
	title += " - "+domain.getTitle().getValue();	
}
String description = domain.getName();
if(domain.getDescription() != null&&!domain.getDescription().getValue().equals("null"))
{
	description += " - "+domain.getDescription().getValue();	
} else {
	description = descriptions;
}

if(description.length() < 100)
{
	description = descriptions;	
}

String keywords = domain.getName()+","+Utils.returnDomain(domain.getName());
if(domain.getKeyword() != null&&!domain.getKeyword().getValue().equals("null"))
{
	keywords += ","+domain.getKeyword().getValue();	
}

%>
<jsp:include page="/layout/header.jsp">
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="description" value="<%=description %>"/>
	<jsp:param name="keywords" value="<%=keywords %>"/>
	<jsp:param name="img" value="<%=domain.getName() %>"/>
</jsp:include>

<div class="b">
	<link itemprop="url" href="http://evaluationsites.appspot.com/site/<%=domain.getName() %>">
    <meta itemprop="name" content="<%=title%>">
    <meta itemprop="description" content="<%=description%>">
	<h1 title="<%=domain.getName() %>"><%=domain.getName() %></h1>
	<p><%=descriptions %></p> 
	<div class="ud">
		Updated<b>
		<%
			if(day > 0)
			{
				out.print(day+" days, ");
			}
			if(hour > 0)
			{
				out.print(hour+" hours, ");
			}
			out.print(minute+" minutes");
		%>	
		</b> Ago
	</div>
	<div class="adt">
		<!-- -->
		<div class="addthis_toolbox addthis_default_style ">
			<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
			<a class="addthis_button_tweet" tw:via="yunievu"></a> <a
				class="addthis_button_google_plusone" g:plusone:size="medium"></a> <a
				class="addthis_counter addthis_pill_style"></a>
		</div>
		<script type="text/javascript"
			src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4f538d0603cbd870"></script>
		<!-- AddThis Button END -->
	</div>
	<div class="cl"></div>
	<div class="ad">
		<%@ include file='/adv/banner702.jsp'%>	
	</div>

	<div class="br">
		<%@ include file='/adv/adv200.jsp'%>	
	</div>

	<ul class="li">
		<li>
			<div class="dl">Domain Name :</div>
			<div class="dr"><%=domain.getName() %> ( <a href="/check-back-link/<%=domain.getName() %>" title="Check back link of <%=domain.getName()%>" rel="nofollow">Check back link</a> )</div>
		</li>
		<li>
			<div class="dl">Google Pagerank :</div>
			<div class="dr"><%=(domain.getGoogle() != null&&!domain.getGoogle().getValue().equals("null"))?domain.getGoogle().getValue():"0" %></div>
		</li>
		<li>
			<div class="dl">Alexa Rank :</div>
			<div class="dr"><%=(domain.getAlexa() != 0)?format.getInstance().format(domain.getAlexa()):"-" %></div>
		</li>
		<li>
			<div class="dl">IP Address :</div>
			<div class="dr"><%=(domain.getIp() != null&&!domain.getIp().equals("null"))?domain.getIp()+" ( <a href='/ip/"+domain.getIp()+"' title='View Track Ip of "+domain.getIp()+"' rel=\"nofollow\">View Track Ip</a> )":"-" %></div>
		</li>
		<li>
			<div class="dl">Speed Site :</div>
			<div class="dr"><%=(domain.getSpeedSite() != null&&!domain.getSpeedSite().getValue().equals("null"))?"<b>"+domain.getSpeedSite().getValue()+"</b> Seconds":"-" %></div>
		</li>
		<li>
			<div class="dl">Age Domain :</div>
			<div class="dr"><%=(domain.getAgeDomain() != null&&!domain.getAgeDomain().getValue().equals("null"))?domain.getAgeDomain().getValue():"-" %></div>
		</li>
		<li>
			<div class="dl">Charset :</div>
			<div class="dr"><%=(domain.getCharset() != null&&!domain.getCharset().getValue().equals("null"))?domain.getCharset().getValue():"-" %></div>
		</li>
	</ul>
	<div class="cl"></div>
	<div class="ld">
		<h2>Site Info</h2>
		<ul class="li">
			<li>
				<div class="dl">Title :</div>
				<div class="dr wid"><%=(domain.getTitle() != null&&!domain.getTitle().getValue().equals("null"))?domain.getTitle().getValue():"No title" %></div>
			</li>
			<li>
				<div class="dl">Description :</div>
				<div class="dr wid"><%=(domain.getDescription() != null&&!domain.getDescription().getValue().equals("null"))?domain.getDescription().getValue():"No description" %></div>
			</li>
			<li>
				<div class="dl">Keyword :</div>
				<div class="dr wid"><%=(domain.getKeyword() != null&&!domain.getKeyword().getValue().equals("null"))?domain.getKeyword().getValue():"No keyword" %></div>
			</li>	
			<li>
				<%@ include file='/adv/menushot.jsp'%>
			</li>
		</ul>
		<div class="cl"></div>
	</div>
	<div class="wot">
		<h2>Mywot.com - Reputation rating</h2>
		<ul>
			<li><b><%=(domain.getWotTrust() != null&&!domain.getWotTrust().getValue().equals("null"))?domain.getWotTrust().getValue():"-" %></b>Trustworthiness:</li>
			<li><b><%=(domain.getWotVendor() != null&&!domain.getWotVendor().getValue().equals("null"))?domain.getWotVendor().getValue():"-" %></b>Vendor reliability:</li>
			<li><b><%=(domain.getWotPrivacy() != null&&!domain.getWotPrivacy().getValue().equals("null"))?domain.getWotPrivacy().getValue():"-" %></b>Privacy:</li>
			<li><b><%=(domain.getWotChild() != null&&!domain.getWotChild().getValue().equals("null"))?domain.getWotChild().getValue():"-" %></b>Child Safety:</li>
		</ul>
	</div>
	<div class="inf">
		<h2>Site Technical Info</h2>
		<ul>
			<li>
				<div class="infl">Programming Language :</div>
				<div class="infr"><%=(domain.getLanguage() != null&&!domain.getLanguage().getValue().equals("null")&&!domain.getLanguage().getValue().equals(""))?domain.getLanguage().getValue():"-" %></div>
			</li>
			<li>
				<div class="infl">Web server :</div>
				<div class="infr"><%=(domain.getServer() != null&&!domain.getServer().getValue().equals("null")&&!domain.getServer().getValue().equals(""))?domain.getServer().getValue():"-" %></div>
			</li>
			<li>
				<div class="infl">Javascript library :</div>
				<div class="infr"><%=(domain.getJsLib() != null&&!domain.getJsLib().getValue().equals("null")&&!domain.getJsLib().getValue().equals(""))?domain.getJsLib().getValue():"-" %></div>
			</li>
		</ul>
	</div>
	<div class="cl"></div>

	<h2>Alexa stats</h2>
	<ul class="b-menu-01">
		<li class="current" id="gr_traffic"><a
			onclick="viewGraphTab('traffic'); return false;" href="#"> <span><b>Traffic
						Rank</b> </span> </a>
		</li>
		<li id="gr_reach" class=""><a
			onclick="viewGraphTab('reach'); return false;" href="#"><b>Reach</b>
		</a>
		</li>
		<li id="gr_page" class=""><a
			onclick="viewGraphTab('page'); return false;" href="#"><b>Pageviews</b>
		</a>
		</li>
		<li id="gr_page_user" class=""><a
			onclick="viewGraphTab('page_user'); return false;" href="#"><b>Pageviews/User</b>
		</a>
		</li>
		<li id="gr_bounce" class=""><a
			onclick="viewGraphTab('bounce'); return false;" href="#"><b>Bounce
					%</b> </a>
		</li>
		<li id="gr_time" class=""><a
			onclick="viewGraphTab('time'); return false;" href="#"><b>Time
					on Site</b> </a>
		</li>
		<li id="gr_search" class=""><a
			onclick="viewGraphTab('search'); return false;" href="#"><b>Search
					%</b> </a>
		</li>
	</ul>
	<form class="f-alexa">
		<div class="f-alexa-left">
			<select id="selectPeriod" class="inp-select">
				<option value="7d">Trailing 7 days</option>
				<option value="1m">Trailing 1 month</option>
				<option selected="selected" value="3m">Trailing 3 months</option>
				<option value="6m">Trailing 6 months</option>
				<option value="2y">Max</option>
			</select>
			<h4>Compare this site to:</h4>
			<input type="text" class="inp-text compare-to"> <input
				type="text" class="inp-text compare-to"> <input type="text"
				class="inp-text compare-to"> <input type="text"
				class="inp-text compare-to"> <input type="button"
				onclick="compareTo(); return false;" value="Compare"
				class="inp-submit-01">
		</div>
		<div class="f-alexa-right">
			<img
				src="http://traffic.alexa.com/graph?&amp;w=400&amp;h=220&amp;o=f&amp;c=1&amp;y=t&amp;b=ffffff&amp;n=666666&amp;r=3m&amp;u=<%=domain.getName() %>"
				id="alexaGraphic">
		</div>
	</form>

	<%
	if(domain.getWhois()!=null && !domain.getWhois().getValue().equals("null"))
	{
	%>
		<h2>Whois ( <a href="/whois/<%=domain.getName()%>" title="More detail">More detail ... </a> )</h2>
		<div class="wh">
			<%=domain.getWhois().getValue()%>
		</div>
	<%
	}
	%>
	<%
	if(domain.getWhoisIp()!=null && !domain.getWhoisIp().getValue().equals("null"))
	{
	%>
		<h2>Whois ip <%=(domain.getIp() != null)?domain.getIp():"-" %></h2>
		<div class="wh">
			<%=domain.getWhoisIp().getValue() %>
		</div>
	<%
	}
	%>
	<div class="ad">
		<%@ include file='/adv/banner.jsp'%>	
	</div>
	<%
	if(domain.getOutlink()!=null && !domain.getOutlink().getValue().equals("null"))
	{
		String[] arrOut = domain.getOutlink().getValue().split(",");
	%>
		<div class="ld">
			<strong>Out link : </strong>
			<%
			for(int i=0;i<arrOut.length;i++)
			{
			%>
				<a href="/site/<%=arrOut[i].trim()%>" title="<%=arrOut[i].trim()%>" rel="nofollow"><%=arrOut[i].trim()%> </a> ,
			<%
			}
			%>
		</div>
	<%
	}
	%>

	<%
	if(domain.getNearSite().size()>0)
	{
	%>
		<div class="ld">
			<strong>Near site :</strong>
			<%
			for(int i=0;i<domain.getNearSite().size();i++)
			{
			%>
				<a href="/site/<%=domain.getNearSite().get(i)%>" title="<%=domain.getNearSite().get(i)%>"><%=domain.getNearSite().get(i)%></a> , 
			<%
			}
			%>
		</div>
	<%
	}
	%>
	
	
</div>
<script>
graphDomain='<%=domain.getName()%>';
</script>
<script type="text/javascript" src="/js/jquery.js"></script>

		<script type="text/javascript" src="/js/re_detail.js"></script>
<%@ include file='/layout/footer.jsp'%>
